package day0726API;

public class Test8 {
    public static void main(String[] args) {
        Thread  restaurant=new Thread(()->{
            Thread thisThread=Thread.currentThread();
            thisThread.setName("餐厅：");
            for(int i=1;i<=50;i++){
                System.out.println(thisThread.getName()+":开门营业");
                System.out.println(thisThread.getName()+":接待顾客");
            }
            System.out.println(thisThread.getName()+":关门");
        });
        restaurant.start();

        Thread  cleaner=new Thread(()->{
            Thread thisThread=Thread.currentThread();
            thisThread.setName("清洁工：");
            while(true){
                System.out.println(thisThread.getName()+":打扫餐厅卫生");
            }
        });
        cleaner.setDaemon(true);//将清洁工设置为后台线程/精灵线程(restaurant线程和main线程结束，则后台线程也会跟着结束)
        System.out.println(cleaner.isDaemon());
        cleaner.start();


    }
}
